// pages/myDiary2/components/card/index.js
import {acceptOrder} from '../../../../apis/order';
import Toast from '../../../../miniprogram_npm/@vant/weapp/toast/toast';
Component({
   /**
    * 组件的属性列表
    */
   properties: {
      item:{
         type:Object,
         value:()=>{
            return {}
         }
      }
   },

   observers:{
   },

   /**
    * 组件的初始数据
    */
   data: {

   },

   /**
    * 组件的方法列表
    */
   methods: {
      accept(e) {
         console.log(e);
         acceptOrder(e.currentTarget.dataset.id).then(res => {
            if (res.code === 200) {
               wx.showToast({
                  title: '接单成功，可前往我的订单查看详情',
                  icon: 'none',
                  duration: 1000,
                  success(res) {
                    setTimeout(function() {
                      wx.redirectTo({
                        url: '/pages/orderHall/orderHall',
                      })
                    }, 1000);
                  }
                })
            } else {
               wx.showToast({
                  title: res.message,
                  icon: 'none'
                })
            }
         })
      }
   }
})
